﻿using System;
using xycn.IDbService;
using xycn.pluginsupport.BaseHelperPlugins;
using xycn.pluginsupport.ControllerPlugins;

namespace ChangYingMes
{
    public class Class1: BaseController
    {
        IDbService _dbhelper = DbHelper.CreateDbService("SqlSugarInterface");

        [HttpMethod(HttpMethodType.GET, "GetAllList")]
        public string GetAllList()
        {
            return "成功";       
        }

        [HttpMethod(HttpMethodType.GET, "asd/{id}")]
        public ReponseContext asd(int ID)
        {
            return _success("ok");
        }

        [HttpMethod(HttpMethodType.GET, "qwe/{qwe}/qwe")]
        [AllowAnonymous]
        public ReponseContext qwe(string qwe)
        {
            return _success(qwe);
        }

        [HttpMethod(HttpMethodType.GET, "s/{id}")]
        public string s(int ID)
        {
            return ID.ToString();
        }

        [HttpMethod(HttpMethodType.POST, "User/GetUsersAllList")]
        public ReponseContext GetAllUsersList()
        {
            try
            {
                var res = _dbhelper.GetList<User>(A => A.Id==1);

                if (res.IsSucceed)
                {
                    return _success(res.Data);
                }
                return _fail(res.Message);
            }
            catch (Exception ex)
            {
                return _error(ex, "/Users/GetUsersAllList");
            }
        }

        public class User
        { 
            public int Id { get; set; }
            public string name { set; get; }
        }
    }
}
